import request from "@/utils/request";
import { parseStrEmpty } from "@/utils/ruoyi";

// 查询表单列表
export function listForm(query) {
  return request({
    url: "/system/form/list",
    method: "get",
    params: query,
  });
}
// 查询表单列表
export function listFormDept(query) {
  return request({
    url: "/system/form/listDept",
    method: "get",
    params: query,
  });
}
// 查询表单详细
export function getForm(formId) {
  return request({
    url: "/system/form/" + parseStrEmpty(formId),
    method: "get",
  });
}
// 新增表单
export function addForm(data) {
  return request({
    url: "/system/form",
    method: "post",
    data: data,
  });
}
// 修改表单
export function updateForm(data) {
  return request({
    url: "/system/form",
    method: "put",
    data: data,
  });
}
// 删除表单
export function delForm(formId) {
  return request({
    url: "/system/form/" + formId,
    method: "delete",
  });
}
// 复制表单
export function copyForm(formId) {
  return request({
    url: "/system/form/copy/" + formId,
    method: "get",
  });
}

// 表单状态修改
export function changeFormStatus(deptId, formId, status) {
  const data = {
    deptId,
    formId,
    status,
  };
  return request({
    url: "/system/form/changeStatus",
    method: "put",
    data: data,
  });
}

// 查询表单内容控件列表带分页的
export function listQuestion(query) {
  return request({
    url: "/system/question/list",
    method: "get",
    params: query,
  });
}
// 查询表单内容控件列表
export function listFormCont(query) {
  return request({
    url: "/system/question/list/all",
    method: "get",
    params: query,
  });
}
// 新增表单内容控件
export function addFormCont(data) {
  return request({
    url: "/system/question",
    method: "post",
    data: data,
  });
}
// 修改表单内容控件
export function updateFormCont(data) {
  return request({
    url: "/system/question",
    method: "put",
    data: data,
  });
}
// 删除表单内容控件

export function delFormCont(questionId) {
  return request({
    url: "/system/question/" + questionId,
    method: "delete",
  });
}

// 新增表单内容答案
export function addFormAnswer(type, data) {
  return request({
    url: "/system/VisitFormLog/" + type,
    method: "post",
    data: data,
  });
}

// 查询就诊单记录列表
export function listCustomerForm(query) {
  return request({
    url: "/system/VisitFormLog/list",
    method: "get",
    params: query,
  });
}


// 查询答案列表
export function listAnswer(query) {
  return request({
    url: "/system/answer/list",
    method: "get",
    params: query,
  });
}

// 修改答案
export function updateAnswer(type, data) {
  return request({
    url: "/system/VisitFormLog/" + type,
    method: "put",
    data: data,
  });
}

//查询通用诊前问卷id
export function currencyFormId(query) {
  return request({
    url: "/system/form/currency",
    method: "get",
    params: query,
  });
}

//获取就诊单详细信息
export function detailFormAndAnswer(visitLogId) {
  return request({
    url: "/system/VisitFormLog/" + visitLogId,
    method: "get",
  });
}

//获取平台表单列表
export function listPlatform(query) {
  return request({
    url: "/system/form/platformList",
    method: "get",
    params: query,
  });
}

//复制平台表单
export function copyPlatform(data, deptId, hospitalId) {
  return request({
    url: "/system/form/copyPlatform/" + deptId + "/" + hospitalId + "/" + data,
    method: "get",
  });
}
